package com.tepth.vehiclemaintenance.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import butterknife.ButterKnife;
import butterknife.Unbinder;
import me.yokeyword.fragmentation.SupportFragment;

/**
 * Created by YoKeyword on 16/2/3.
 */
public abstract class BaseFragment extends SupportFragment {

    protected abstract void setPresenter();

    protected abstract void unbindPresenter();

    protected abstract void initView(View view);

    protected abstract View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState);
    private Unbinder unbinder;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        setPresenter();
        View view = createView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this,view);
        initView(view);
        return view;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbindPresenter();
        unbinder.unbind();
    }

}
